#include <iostream>

using std::cout;
using std::endl;

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {   cout << "Point(int,int)" << endl;   }

    void print() const
    {
        cout << "(" << _ix 
             << "," << _iy
             << ")" << endl;
    }

private:
    int _ix;
protected:
    int _iy;
};

class Point3D 
: private Point
{
public:
    Point3D(int ix, int iy, int iz)
    : Point(ix, iy)
    , _iz(iz)
    {   cout << "Point3D(int,int,int)" << endl; }

    //新的功能
    void display() const
    {
        //cout << "_ix:" << _ix << endl; //无法访问
        //基类保护成员，在派生类中是private的
        cout << "_iy:" << _iy << endl;//ok
        cout << "_iz:" << _iz << endl;
    }
    

private:
    int _iz;
};

class Point4D
: public Point3D
{
public:
    void show() const
    {
        //顶层基类Point的_iy成员，不可以在Point4D内部直接访问
        cout << "_iy:" << _iy << endl;
    }
};

int main()
{
    cout << "sizeof(Point):" << sizeof(Point) << endl;
    cout << "sizeof(Point3D):" << sizeof(Point3D) << endl;
    Point3D pt1(1, 2, 3);
    pt1.display();
    //print函数在Point3D是private的
    //pt1.print();//error, 派生类对象访问, 私有继承基类的公有成员

    return 0;
}

